home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / cop01.c < prev    next >
C/C++ Source or Header  |  2000-05-04  |  13KB  |  406 lines

  1. /***************************************************************************
  2. Cops 01
  3. Nichibutsu - 1985
  4.  
  5. calb@gsyc.inf.uc3m.es
  6.  
  7. TODO:
  8. ----
  9. - Fix colors. (it isn't using the lookup proms)
  10. - Fix sprites bank. (ahhhghg!)
  11. - Fix sprites clip.
  12.  
  13.  
  14. MEMORY MAP
  15. ----------
  16. 0000-BFFF  ROM
  17. C000-C7FF  RAM
  18. D000-DFFF  VRAM (Background)
  19. E000-E0FF  VRAM (Sprites)
  20. F000-F3FF  VRAM (Foreground)
  21.  
  22. AUDIO MEMORY MAP (Advise: Real audio chip used, UNKNOWN)
  23. ----------------
  24. 0000-7FFF  ROM
  25. 8000-8000  UNKNOWN
  26. C000-C700  RAM
  27.  
  28. ***************************************************************************/
  29. #include "driver.h"
  30. #include "vidhrdw/generic.h"
  31.  
  32. void cop01_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  33. void cop01_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  34. WRITE_HANDLER( cop01_scrollx_w );
  35. WRITE_HANDLER( cop01_gfxbank_w );
  36. int cop01_vh_start(void);
  37. void cop01_vh_stop(void);
  38.  
  39. extern unsigned char *cop01_videoram;
  40. extern size_t cop01_videoram_size;
  41.  
  42.  
  43.  
  44. WRITE_HANDLER( cop01_sound_command_w )
  45. {
  46.     soundlatch_w(offset,data);
  47.     cpu_cause_interrupt(1,0xff);
  48. }
  49.  
  50. READ_HANDLER( cop01_sound_command_r )
  51. {
  52.     int res;
  53.     static int pulse;
  54. #define TIMER_RATE 12000    /* total guess */
  55.  
  56.  
  57.     res = (soundlatch_r(offset) & 0x7f) << 1;
  58.  
  59.     /* bit 0 seems to be a timer */
  60.     if ((cpu_gettotalcycles() / TIMER_RATE) & 1)
  61.     {
  62.         if (pulse == 0) res |= 1;
  63.         pulse = 1;
  64.     }
  65.     else pulse = 0;
  66.  
  67.     return res;
  68. }
  69.  
  70.  
  71. static struct MemoryReadAddress readmem[] =
  72. {
  73.     { 0x0000, 0xbfff, MRA_ROM },
  74.     { 0xc000, 0xc7ff, MRA_RAM },
  75.     { 0xd000, 0xdfff, MRA_RAM },
  76.     { 0xe000, 0xe0ff, MRA_RAM },
  77.     { -1 }    /* end of table */
  78. };
  79.  
  80. static struct MemoryWriteAddress writemem[] =
  81. {
  82.     { 0x0000, 0xbfff, MWA_ROM },
  83.     { 0xc000, 0xc7ff, MWA_RAM },
  84.     { 0xd000, 0xd7ff, videoram_w, &videoram, &videoram_size },
  85.     { 0xd800, 0xdfff, colorram_w, &colorram },
  86.     { 0xe000, 0xe0ff, MWA_RAM, &spriteram, &spriteram_size },
  87.     { 0xf000, 0xf3ff, MWA_RAM, &cop01_videoram, &cop01_videoram_size },
  88.     { -1 }    /* end of table */
  89. };
  90.  
  91. static struct IOReadPort readport[] =
  92. {
  93.     { 0x00, 0x00, input_port_0_r },
  94.     { 0x01, 0x01, input_port_1_r },
  95.     { 0x02, 0x02, input_port_2_r },
  96.     { 0x03, 0x03, input_port_3_r },
  97.     { 0x04, 0x04, input_port_4_r },
  98.     { -1 }    /* end of table */
  99. };
  100.  
  101. static struct IOWritePort writeport[] =
  102. {
  103.     { 0x40, 0x40, cop01_gfxbank_w },
  104.     { 0x41, 0x42, cop01_scrollx_w },
  105.     { 0x44, 0x44, cop01_sound_command_w },
  106.     { -1 }    /* end of table */
  107. };
  108.  
  109. static struct MemoryReadAddress sound_readmem[] =
  110. {
  111.     { 0x0000, 0x7fff, MRA_ROM },
  112.     { 0xc000, 0xc7ff, MRA_RAM },
  113.     { -1 }    /* end of table */
  114. };
  115.  
  116. static struct MemoryWriteAddress sound_writemem[] =
  117. {
  118.     { 0x0000, 0x7fff, MWA_ROM },
  119.     { 0xc000, 0xc7ff, MWA_RAM },
  120.     { -1 }
  121. };
  122.  
  123. static struct IOReadPort sound_readport[] =
  124. {
  125.     { 0x06, 0x06, cop01_sound_command_r },
  126.     { -1 }    /* end of table */
  127. };
  128.  
  129. static struct IOWritePort sound_writeport[] =
  130. {
  131.     { 0x00, 0x00, AY8910_control_port_0_w },
  132.     { 0x01, 0x01, AY8910_write_port_0_w },
  133.     { 0x02, 0x02, AY8910_control_port_1_w },
  134.     { 0x03, 0x03, AY8910_write_port_1_w },
  135.     { 0x04, 0x04, AY8910_control_port_2_w },
  136.     { 0x05, 0x05, AY8910_write_port_2_w },
  137.     { -1 }    /* end of table */
  138. };
  139.  
  140.  
  141.  
  142. INPUT_PORTS_START( cop01 )
  143.     PORT_START      /* IN0 */
  144.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY )
  145.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY )
  146.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY )
  147.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  148.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
  149.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  150.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  151.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  152.  
  153.     PORT_START      /* IN1 */
  154.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP | IPF_8WAY | IPF_COCKTAIL )
  155.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN | IPF_8WAY | IPF_COCKTAIL  )
  156.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT | IPF_8WAY | IPF_COCKTAIL  )
  157.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_COCKTAIL  )
  158.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_COCKTAIL  )
  159.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_COCKTAIL  )
  160.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  161.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  162.  
  163.     PORT_START  /* TEST, COIN, START */
  164.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
  165.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
  166.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
  167.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 )
  168.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_COIN3 )
  169.     PORT_SERVICE( 0x20, IP_ACTIVE_LOW )
  170.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
  171.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  172.  
  173.     PORT_START    /* DSW1 */
  174.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) )
  175.     PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) )
  176.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
  177.     PORT_DIPSETTING(    0x01, DEF_STR( 1C_2C ) )
  178.     PORT_DIPSETTING(    0x00, DEF_STR( Free_Play ) )
  179.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_B ) )
  180.     PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
  181.     PORT_DIPSETTING(    0x08, DEF_STR( 2C_3C ) )
  182.     PORT_DIPSETTING(    0x0c, DEF_STR( 1C_3C ) )
  183.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_6C ) )
  184.     PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
  185.     PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
  186.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  187.     PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
  188.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  189.     PORT_DIPSETTING(    0x20, DEF_STR( On ) )
  190.     PORT_DIPNAME( 0x40, 0x40, DEF_STR( Flip_Screen ) )
  191.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  192.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  193.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Cabinet ) )
  194.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  195.     PORT_DIPSETTING(    0x80, DEF_STR( Cocktail ) )
  196.  
  197.     PORT_START    /* DSW2 */
  198.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
  199.     PORT_DIPSETTING(    0x03, "Easy" )
  200.     PORT_DIPSETTING(    0x01, "Medium" )
  201.     PORT_DIPSETTING(    0x02, "Hard" )
  202.     PORT_DIPSETTING(    0x00, "Hardest" )
  203.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) )
  204.     PORT_DIPSETTING(    0x0c, "3" )
  205.     PORT_DIPSETTING(    0x04, "4" )
  206.     PORT_DIPSETTING(    0x08, "5" )
  207.     PORT_DIPSETTING(    0x00, "6" )
  208.     PORT_DIPNAME( 0x10, 0x10, "1st Bonus Life" )
  209.     PORT_DIPSETTING(    0x10, "20000" )
  210.     PORT_DIPSETTING(    0x00, "30000" )
  211.     PORT_DIPNAME( 0x60, 0x60, "2nd Bonus Life" )
  212.     PORT_DIPSETTING(    0x60, "30000" )
  213.     PORT_DIPSETTING(    0x20, "50000" )
  214.     PORT_DIPSETTING(    0x40, "100000" )
  215.     PORT_DIPSETTING(    0x00, "150000" )
  216.     PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
  217.     PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
  218.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  219. INPUT_PORTS_END
  220.  
  221.  
  222.  
  223. static struct GfxLayout charlayout =
  224. {
  225.     8,8,    /* 8*8 characters */
  226.     256,    /* 256 characters */
  227.     4,    /* 4 bits per pixel */
  228.     { 0, 1, 2, 3 },
  229.     { 4, 0, 12, 8, 20, 16, 28, 24 },
  230.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
  231.     32*8    /* every char takes 32 consecutive bytes */
  232. };
  233.  
  234. static struct GfxLayout tilelayout =
  235. {
  236.     8,8,    /* 8*8 characters */
  237.     1024,    /* 1024 characters */
  238.     4,    /* 4 bits per pixel */
  239.     { 0, 1, 2, 3 },
  240.     { 4, 0, 12, 8, 20, 16, 28, 24 },
  241.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
  242.     32*8    /* every char takes 32 consecutive bytes */
  243. };
  244.  
  245. static struct GfxLayout spritelayout =
  246. {
  247.     16,16,    /* 16*16 sprites */
  248.     512,    /* 512 sprites */
  249.     4,    /* 4 bits per pixel */
  250.     { 0, 1, 2, 3 }, /* plane offset */
  251.     { 4, 0, 4+512*64*8, 0+512*64*8, 12, 8, 12+512*64*8, 8+512*64*8,
  252.             20, 16, 20+512*64*8, 16+512*64*8, 28, 24, 28+512*64*8, 24+512*64*8 },
  253.     { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
  254.             8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32 },
  255.     64*8
  256. };
  257.  
  258. static struct GfxDecodeInfo gfxdecodeinfo[] =
  259. {
  260.     { REGION_GFX1, 0, &charlayout,            0, 16 },    /* ?? */
  261.     { REGION_GFX2, 0, &tilelayout,        16*16,  4 },
  262.     { REGION_GFX3, 0, &spritelayout, 16*16+4*16, 16 },
  263.     { -1 }
  264. };
  265.  
  266.  
  267.  
  268. static struct AY8910interface ay8910_interface =
  269. {
  270.     3,    /* 3 chips */
  271.     1500000,    /* 1.5 MHz?????? */
  272.     { 25, 25, 25 },
  273.     { 0 },
  274.     { 0 },
  275.     { 0 },
  276.     { 0 }
  277. };
  278.  
  279.  
  280.  
  281. static struct MachineDriver machine_driver_cop01 =
  282. {
  283.     /* basic machine hardware */
  284.     {
  285.         {
  286.             CPU_Z80,
  287.             3500000,        /* 3.5 Mhz (?) */
  288.             readmem,writemem,readport,writeport,
  289.             interrupt,1
  290.         },
  291.         {
  292.             CPU_Z80 | CPU_AUDIO_CPU,
  293.             3000000,        /* 3.0 Mhz (?) */
  294.             sound_readmem,sound_writemem,sound_readport,sound_writeport,
  295.             ignore_interrupt,0    /* IRQs are caused by the main CPU */
  296.         },
  297.     },
  298.     60,DEFAULT_60HZ_VBLANK_DURATION,
  299.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  300.     0, /* init machine */
  301.  
  302.     /* video hardware */
  303.     32*8, 32*8, { 0, 32*8-1, 2*8, 30*8-1 },
  304.     gfxdecodeinfo,
  305.     256, 16*16+4*16+16*16,
  306.     cop01_vh_convert_color_prom,
  307.  
  308.     VIDEO_TYPE_RASTER,
  309.     0,
  310.     cop01_vh_start,
  311.     cop01_vh_stop,
  312.     cop01_vh_screenrefresh,
  313.  
  314.     /* sound hardware */
  315.     0,0,0,0,
  316.     {
  317.         {
  318.             SOUND_AY8910,
  319.             &ay8910_interface
  320.         }
  321.     }
  322. };
  323.  
  324.  
  325. /***************************************************************************
  326.  
  327.   Game driver(s)
  328.  
  329. ***************************************************************************/
  330.  
  331.  
  332. ROM_START( cop01 )
  333.     ROM_REGION( 0x10000, REGION_CPU1 )     /* 64k for code */
  334.     ROM_LOAD( "cop01.2b",     0x0000, 0x4000, 0x5c2734ab )
  335.     ROM_LOAD( "cop02.4b",     0x4000, 0x4000, 0x9c7336ef )
  336.     ROM_LOAD( "cop03.5b",     0x8000, 0x4000, 0x2566c8bf )
  337.  
  338.     ROM_REGION( 0x10000, REGION_CPU2 )     /* 64k for code */
  339.     ROM_LOAD( "cop15.17b",    0x0000, 0x4000, 0x6a5f08fa )
  340.     ROM_LOAD( "cop16.18b",    0x4000, 0x4000, 0x56bf6946 )
  341.  
  342.     ROM_REGION( 0x02000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  343.     ROM_LOAD( "cop14.15g",    0x00000, 0x2000, 0x066d1c55 )    /* chars */
  344.  
  345.     ROM_REGION( 0x08000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  346.     ROM_LOAD( "cop04.15c",    0x00000, 0x4000, 0x622d32e6 )    /* tiles */
  347.     ROM_LOAD( "cop05.16c",    0x04000, 0x4000, 0xc6ac5a35 )
  348.  
  349.     ROM_REGION( 0x10000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  350.     ROM_LOAD( "cop10.3e",     0x00000, 0x2000, 0x444cb19d )    /* sprites */
  351.     ROM_LOAD( "cop11.5e",     0x02000, 0x2000, 0x9078bc04 )
  352.     ROM_LOAD( "cop12.6e",     0x04000, 0x2000, 0x257a6706 )
  353.     ROM_LOAD( "cop13.8e",     0x06000, 0x2000, 0x07c4ea66 )
  354.     ROM_LOAD( "cop06.3g",     0x08000, 0x2000, 0xf1c1f4a5 )
  355.     ROM_LOAD( "cop07.5g",     0x0a000, 0x2000, 0x11db7b72 )
  356.     ROM_LOAD( "cop08.6g",     0x0c000, 0x2000, 0xa63ddda6 )
  357.     ROM_LOAD( "cop09.8g",     0x0e000, 0x2000, 0x855a2ec3 )
  358.  
  359.     ROM_REGION( 0x0500, REGION_PROMS )
  360.     ROM_LOAD( "copproma.13d", 0x0000, 0x0100, 0x97f68a7a )    /* red */
  361.     ROM_LOAD( "coppromb.14d", 0x0100, 0x0100, 0x39a40b4c )    /* green */
  362.     ROM_LOAD( "coppromc.15d", 0x0200, 0x0100, 0x8181748b )    /* blue */
  363.     ROM_LOAD( "coppromd.19d", 0x0300, 0x0100, 0x6a63dbb8 )    /* lookup table? (not implemented) */
  364.     ROM_LOAD( "copprome.2e",  0x0400, 0x0100, 0x214392fa )    /* sprite lookup table */
  365. ROM_END
  366.  
  367. ROM_START( cop01a )
  368.     ROM_REGION( 0x10000, REGION_CPU1 )     /* 64k for code */
  369.     ROM_LOAD( "cop01alt.001", 0x0000, 0x4000, 0xa13ee0d3 )
  370.     ROM_LOAD( "cop01alt.002", 0x4000, 0x4000, 0x20bad28e )
  371.     ROM_LOAD( "cop01alt.003", 0x8000, 0x4000, 0xa7e10b79 )
  372.  
  373.     ROM_REGION( 0x10000, REGION_CPU2 )     /* 64k for code */
  374.     ROM_LOAD( "cop01alt.015", 0x0000, 0x4000, 0x95be9270 )
  375.     ROM_LOAD( "cop01alt.016", 0x4000, 0x4000, 0xc20bf649 )
  376.  
  377.     ROM_REGION( 0x02000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  378.     ROM_LOAD( "cop01alt.014", 0x00000, 0x2000, 0xedd8a474 )    /* chars */
  379.  
  380.     ROM_REGION( 0x08000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  381.     ROM_LOAD( "cop04.15c",    0x00000, 0x4000, 0x622d32e6 )    /* tiles */
  382.     ROM_LOAD( "cop05.16c",    0x04000, 0x4000, 0xc6ac5a35 )
  383.  
  384.     ROM_REGION( 0x10000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  385.     ROM_LOAD( "cop01alt.010", 0x00000, 0x2000, 0x94aee9d6 )    /* sprites */
  386.     ROM_LOAD( "cop11.5e",     0x02000, 0x2000, 0x9078bc04 )
  387.     ROM_LOAD( "cop12.6e",     0x04000, 0x2000, 0x257a6706 )
  388.     ROM_LOAD( "cop13.8e",     0x06000, 0x2000, 0x07c4ea66 )
  389.     ROM_LOAD( "cop01alt.006", 0x08000, 0x2000, 0xcac7dac8 )
  390.     ROM_LOAD( "cop07.5g",     0x0a000, 0x2000, 0x11db7b72 )
  391.     ROM_LOAD( "cop08.6g",     0x0c000, 0x2000, 0xa63ddda6 )
  392.     ROM_LOAD( "cop09.8g",     0x0e000, 0x2000, 0x855a2ec3 )
  393.  
  394.     ROM_REGION( 0x0500, REGION_PROMS )
  395.     ROM_LOAD( "copproma.13d", 0x0000, 0x0100, 0x97f68a7a )    /* red */
  396.     ROM_LOAD( "coppromb.14d", 0x0100, 0x0100, 0x39a40b4c )    /* green */
  397.     ROM_LOAD( "coppromc.15d", 0x0200, 0x0100, 0x8181748b )    /* blue */
  398.     ROM_LOAD( "coppromd.19d", 0x0300, 0x0100, 0x6a63dbb8 )    /* lookup table? (not implemented) */
  399.     ROM_LOAD( "copprome.2e",  0x0400, 0x0100, 0x214392fa )    /* sprite lookup table */
  400. ROM_END
  401.  
  402.  
  403.  
  404. GAMEX( 1985, cop01,  0,     cop01, cop01, 0, ROT0, "Nichibutsu", "Cop 01 (set 1)", GAME_IMPERFECT_COLORS )
  405. GAMEX( 1985, cop01a, cop01, cop01, cop01, 0, ROT0, "Nichibutsu", "Cop 01 (set 2)", GAME_IMPERFECT_COLORS )
  406.